<?php
	echo ":: loading config...\r\n";
	extract($_POST);
	extract($_GET);
	unset($_POST,$_GET);

	if(isset($pn)){
		$con = mysql_connect('localhost', 'root', 'root');
		if (!$con){
			die('Could not connect: ' . mysql_error());
		}
	
		if (!mysql_select_db('image', $con)){
			die('ERROR: ' . mysql_error());
		}
		
		mysql_query("SET NAMES 'UTF8'");
		
		$result = mysql_query("select * from imagelist where `PC_PN`='${pn}'", $con);
		$num = mysql_num_rows($result);

		if ($num == 1){
			$row = mysql_fetch_assoc($result);
			echo "set PC_PN=${row['PC_PN']}\r\n";
			echo "set IMG_PATH=${row['IMG_PATH']}\r\n";
			echo "set IMG_SCRIPT=${row['IMG_SCRIPT']}\r\n";
			echo "set IMG_TYPE=${row['IMG_TYPE']}\r\n";
			echo "set HAS_SSD1=${row['HAS_SSD1']}\r\n";
			echo "set HAS_SSD2=${row['HAS_SSD2']}\r\n";
			echo "set HAS_HDD=${row['HAS_HDD']}\r\n";
			echo "set ERRCODE=0\r\n";
		}else if($num > 1){
			echo "ERROR: Part number more than 1 record";
			echo "set ERRCODE=1\r\n";
		}else{
			echo "ERROR: No Part number was found";
			echo "set ERRCODE=1\r\n";
		}
		mysql_close($con);
	}else{
		echo "ERROR: No Part number was set";
		echo "set ERRCODE=1\r\n";
	}
?>